package com.itheima.dao.impl;


import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/*此类用于抽取重复代码*/

/*这个类spring其实为我们写好了*/
public class JdbcDaoSupport {
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    private DataSource dataSource;

    public void setDataSource(DataSource dataSource) {

        if(jdbcTemplate==null){
            jdbcTemplate=new JdbcTemplate(dataSource);
        }
    }
}
